<template>
    <div class="header">
        <div class="content-wrapper">
            <div class="avatar">
                <img :src="seller.avatar" alt>
            </div>
            <div class="content">
                <div class="title">
                    <span class="brand"></span>
                    <span class="name">{{seller.name}}</span>
                </div>
                <div class="desc">{{seller.description}} / {{seller.deliveryTime}}分钟送达</div>
                <div v-if="seller.supports" class="support">
                    <span class="icon" :class="iconClassMap[seller.supports[0].type]"></span>
                    <span class="text">{{seller.supports[0].description}}</span>
                </div>
            </div>
            <div v-if="seller.supports" class="support-count" @click="showDetailAction">
                <span class="count">{{seller.supports.length}}个</span>
                <span class="icon-keyboard_arrow_right"></span>
            </div>
        </div>
        <div class="bulletin-wrapper" @click="showDetailAction">
            <span class="bulletin-title"></span>
            <span class="bulletin-text">{{seller.bulletin}}</span>
            <span class="icon-keyboard_arrow_right"></span>
        </div>
        <div class="background">
            <img :src="seller.avatar" alt>
        </div>
        <transition name="fade">
            <div v-show="detailShow" class="detail">
                <div class="detail-wrapper clearfix">
                    <div class="detail-main">
                        <div class="detail-main-title">{{seller.name}}</div>
                        <div class="detail-main-star">
                            <v-star :score="seller.score" :size="48"></v-star>
                        </div>
                        <v-line-title class="line-title" title="优惠信息"></v-line-title>
                        <v-seller-support class="seller-supports" :supports="seller.supports"></v-seller-support>
                        <v-line-title class="line-title" title="商家公告"></v-line-title>
                        <div class="text">{{seller.bulletin}}</div>
                        <div class="text">{{seller.bulletin}}</div>
                        <div class="text">{{seller.bulletin}}</div>
                        <div class="text">{{seller.bulletin}}</div>
                        <div class="text">{{seller.bulletin}}</div>
                        <div class="text">{{seller.bulletin}}</div>
                        <div class="text">{{seller.bulletin}}</div>
                        <div class="text">{{seller.bulletin}}</div>
                        <div class="text">{{seller.bulletin}}</div>
                    </div>
                </div>
                <div class="detail-close" @click="hideDetailAction">
                    <span class="icon-close"></span>
                </div>
            </div>
        </transition>
    </div>
</template>

<script>
import vStar from './star'
import vLineTitle from './linetitle'
import vSellerSupport from './sellerSupports'

export default {
    props: {
        seller: {
            type: Object
        }
    },
    data() {
        return {
            detailShow: false
        }
    },
    computed: {
        iconClassMap() {
            return ['deserase', 'discount', 'special', 'invoice', 'guarantee']
        }
    },
    methods: {
        showDetailAction() {
            this.detailShow = true
        },
        hideDetailAction() {
            this.detailShow = false
        }
    },
    components: {
        vStar,
        vLineTitle,
        vSellerSupport
    }
}
</script>

<style lang="less">
.header {
    color: #fff;
    background: rgba(7, 17, 27, 0.5);
    overflow: hidden;
    position: relative;
    .content-wrapper {
        position: relative;
        display: flex;
        padding: 24px 12px 18px 40px;
        .avatar {
            display: inline-block;
            vertical-align: top;
            img {
                width: 64px;
                height: 64px;
                border-radius: 2px;
            }
        }
        .content {
            display: flex;
            width: 100%;
            flex-direction: column;
            justify-content: space-between;
            padding: 0 16px;
            .title {
                font-size: 14px;
                margin: 2px 0 0 0;
                .brand {
                    display: inline-block;
                    width: 30px;
                    height: 18px;
                    background-image: url('../../assets/resource/img/brand@3x.png');
                    background-size: 30px 18px;
                    background-repeat: no-repeat;
                }
                .name {
                    display: inline-block;
                    font-size: 16px;
                    line-height: 18px;
                    font-weight: 18px;
                    vertical-align: top;
                }
            }
            .desc {
                font-size: 12px;
                line-height: 12px;
            }
            .support {
                display: flex;
                padding-bottom: 3px;
                .icon {
                    display: inline-block;
                    margin-right: 5px;
                    width: 12px;
                    height: 12px;
                    vertical-align: top;
                    background-size: 12px 12px;
                    background-repeat: no-repeat;
                    &.deserase {
                        background-image: url('../../assets/resource/img/decrease_1@3x.png');
                    }
                    &.discount {
                        background-image: url('../../assets/resource/img/discount_1@3x.png');
                    }
                    &.guarantee {
                        background-image: url('../../assets/resource/img/guarantee_1@3x.png');
                    }
                    &.invoice {
                        background-image: url('../../assets/resource/img/invoice_1@3x.png');
                    }
                    &.special {
                        background-image: url('../../assets/resource/img/special_1@3x.png');
                    }
                }
                .text {
                    display: inline-block;
                    height: 12px;
                    font-size: 10px;
                    line-height: 12px;
                }
            }
        }
        .support-count {
            position: absolute;
            display: inline-block;
            right: 12px;
            bottom: 18px;
            padding: 0 8px;
            height: 24px;
            line-height: 24px;
            border-radius: 14px;
            background: rgba(0, 0, 0, 0.2);
            text-align: center;
            font-size: 0px;
            .count {
                font-size: 14px;
                line-height: 24px;
                margin-left: 2px;
                vertical-align: top;
            }
            .icon-keyboard_arrow_right {
                font-size: 14px;
                line-height: 24px;
                margin-left: 2px;
            }
        }
    }
    .bulletin-wrapper {
        height: 28px;
        position: relative;
        line-height: 28px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        padding-right: 15px;
        background-color: rgba(7, 17, 27, 0.2);
        .bulletin-title {
            display: inline-block;
            width: 22px;
            height: 12px;
            background-image: url('../../assets/resource/img/bulletin@3x.png');
            background-repeat: no-repeat;
            background-size: 22px 12px;
            margin-left: 10px;
            vertical-align: top;
            margin-top: 8px;
        }
        .bulletin-text {
            font-size: 14px;
            margin: auto 15px auto 5px;
            vertical-align: top;
        }
        .icon-keyboard_arrow_right {
            position: absolute;
            right: 10px;
            font-size: 14px;
            line-height: 28px;
        }
    }
    .background {
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        z-index: -1;
        filter: blur(15px);
        img {
            width: 100%;
            height: 100%;
            background-size: auto;
        }
    }
    .detail {
        position: fixed;
        z-index: 200;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
        background-color: rgba(7, 17, 27, 0.8);
        backdrop-filter: blur(10px);
        .detail-wrapper {
            min-height: 100%;
            width: 100%;
            .detail-main {
                margin-top: 64px;
                padding-bottom: 64px;
                text-align: center;
                .detail-main-title {
                    line-height: 16px;
                    height: 16px;
                    margin-bottom: 18px;
                }
                .line-title {
                    margin: 20px auto 10px auto;
                    width: 80%;
                }
                .seller-supports {
                    margin-left: 15%;
                    margin-bottom: 40px;
                }
                .text {
                    margin: 0 15%;
                    text-align: left;
                    font-size: 14px;
                    line-height: 30px;
                }
            }
        }
        .detail-close {
            position: relative;
            width: 32px;
            height: 32px;
            margin: -64px auto;
            clear: both;
            font-size: 32px;
        }
    }
}
.fade-enter-active,
.fade-leave-active {
    transition: all 0.25s;
}
.fade-enter,
.fade-leave-to {
    opacity: 0;
}
</style>
